package com.yjhb.android.sbz.activity;

import android.widget.FrameLayout;

import androidx.viewpager.widget.ViewPager;

import com.yjhb.android.sbz.R;
import com.yjhb.android.sbz.activity.rule.RuleTaskRewardActivity;
import com.yjhb.android.sbz.fragment.reward.FragmentGameReward;
import com.yjhb.android.sbz.fragment.reward.FragmentMoneyMakeReward;
import com.jojo.android.zxlib.adapter.FragmentAdapter;
import com.jojo.android.zxlib.base.BaseFragment;
import com.jojo.android.zxlib.base.mvp.BasePresenter;
import com.jojo.android.zxlib.tool.ZxActivityTool;
import com.jojo.android.zxlib.view.tablayout.SegmentTabLayout;
import com.jojo.android.zxlib.view.tablayout.listener.OnTabSelectListener;

import java.util.ArrayList;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * 创建者 zx
 * 创建时间 2021/2/8 15:24
 */
public class UserRewardActivity extends BaseActivity {
    private final String TAG = "UserRewardActivity";
    @BindView(R.id.back)
    FrameLayout back;
    @BindView(R.id.segmentTabLayout)
    SegmentTabLayout segmentTabLayout;
    @BindView(R.id.viewpager)
    ViewPager viewpager;

    String[] titles = new String[]{"赚钱奖励", "游戏奖励"};
    ArrayList<BaseFragment> fragments = new ArrayList<>();
    //    FragmentPromotionReward fragmentPromotionReward;
    FragmentMoneyMakeReward fragmentMakeMoneyReward;
    FragmentGameReward fragmentGameReward;

    @Override
    protected boolean isCheckLogin() {
        return true;
    }

    @Override
    protected BasePresenter initPresenter() {
        return null;
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_user_reward;
    }

    @Override
    protected void initUI() {
        fragments.clear();
//        fragments.add(fragmentPromotionReward = new FragmentPromotionReward());
        fragments.add(fragmentMakeMoneyReward = new FragmentMoneyMakeReward());
        fragments.add(fragmentGameReward = new FragmentGameReward());
        segmentTabLayout.setTabData(titles);
        viewpager.setAdapter(new FragmentAdapter(getSupportFragmentManager(), fragments));

    }

    @Override
    protected void initData() {

    }

    @Override
    protected void regEvent() {
        segmentTabLayout.setOnTabSelectListener(new OnTabSelectListener() {
            @Override
            public void onTabSelect(int position) {
                viewpager.setCurrentItem(position, true);
            }

            @Override
            public void onTabReselect(int position) {

            }
        });
        viewpager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
            @Override
            public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

            }

            @Override
            public void onPageSelected(int position) {
                segmentTabLayout.setCurrentTab(position);
            }

            @Override
            public void onPageScrollStateChanged(int state) {

            }
        });
    }


    @OnClick(R.id.back)
    void back() {
        finish();
    }

    @OnClick(R.id.title_right_tv)
    void title_right_tv() {
        ZxActivityTool.skipActivity(this, RuleTaskRewardActivity.class);
    }

}
